package com.niodata.dp.util;

import java.util.LinkedHashMap;
import java.util.Map;

public class Maps<K, V> {

  private final Map<K, V> map = new LinkedHashMap<>();

  private Maps() {
    // empty
  }

  public static <K, V> Maps<K, V> of(K key, V value) {
    Maps<K, V> maps = new Maps<>();
    return maps.append(key, value);
  }

  public static <K, V> Maps<K, V> of(K[] keys, V[] values) {
    Maps<K, V> maps = new Maps<>();
    for (int i = 0; i < keys.length; i++) {
      maps.append(keys[i], values[i]);
    }
    return maps;
  }

  public static <K, V> Maps<K, V> of(KeyValuePair... pairs) {
    Maps<K, V> maps = new Maps<>();
    for (KeyValuePair pair : pairs) {
      maps.append((K) pair.getKey(), (V) pair.getValue());
    }
    return maps;
  }


  public final Maps<K, V> append(K key, V value) {
    this.map.put(key, value);
    return this;
  }

  public final Map<K, V> get() {
    return this.map;
  }


}
